package com.qinker.oa.service.impl;

import com.qinker.oa.dao.UserDao;
import com.qinker.oa.model.User;
import com.qinker.oa.service.UserService;
import com.qinker.oa.utils.DigestUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public User userLogin(User user) {
        user.setPassword(DigestUtil.digest(user.getPassword()));
        return userDao.login(user);
    }

    @Override
    public int[] getUserByName(String nickname) {
        nickname = "%" + nickname + "%";
        return userDao.getUserByName(nickname);
    }
}
